<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	
	<xsl:include href="../admin.xsl" />
	<xsl:include href="../cp/path.xsl" />
	
	<!-- Запускаем рендер страницы -->
	<xsl:template match="/data">
		<html>
		
		<head>
			<title>
				<xsl:value-of select="$pageTitle" />
			</title>
			<xsl:call-template name="meta-head" />
		</head>
		<body>
			<xsl:call-template name="admin-header" />
			
			<div id="blocks">
				<div id="blocks_inner" />
			</div>
			
			<div id="content">
				<div id="content_inner">
					<xsl:apply-templates select="response" />
				</div>
			</div>
			
			<xsl:call-template name="footer" />
		</body>
		</html>
	</xsl:template>
	
	<xsl:template match="response">
		<xsl:param name="cntRequests" select="count(object[@type='user_delete'])" />
		
		<div id="path">
			<xsl:apply-templates select="document('xmodule://cp/getPath/0;users;delete')/data/response" mode="cp-path" />
		</div>
		
		<h1>Удаление пользователей</h1>
		
		<xsl:apply-templates select="message" />
		<xsl:apply-templates select="error" />
		
		<form action="" method="post">
			<p>
				<xsl:text>Логин: </xsl:text>
				<input type="text" name="login" value="" size="20" />
				<xsl:text> </xsl:text>
				<input type="submit" value="Удалить" />
			</p>
		</form>
		
		<h2>Заявки на удаление</h2>
		
		<xsl:if test="$cntRequests = 0">
			<p>Заявок нет.</p>
		</xsl:if>
		
		<xsl:if test="$cntRequests != 0">
			<form action="" method="post">		
				<xsl:apply-templates select="object[@type='user_delete']" />
				
				<p>
					<input type="submit" value="Удалить выбранные" />
				</p>
			</form>
		</xsl:if>
	</xsl:template>
	
	<xsl:template match="object[@type='user_delete']">
		<xsl:param name="login" select="property[@name='user_login']/value" />
		
		<div>
			<input type="checkbox" name="request[]" value="{@id}" />
			<xsl:text> </xsl:text>
			<a href="{$baseURI}/user/{$login}">
				<xsl:value-of select="property[@name='user_name']/value" />
			</a>
			<xsl:text> (</xsl:text>
			<a href="{$baseURI}/admin/users/delete_request/{@id}?scode={$scode}">отменить</a>
			<xsl:text>) </xsl:text>
		</div>
	</xsl:template>
	
</xsl:stylesheet>